'use strict';

module.exports = app => {
  const { STRING, DATE, BIGINT, BOOLEAN, INTEGER, DECIMAL } = app.Sequelize;

  const User = app.model.define('user', {
    id: { type: BIGINT, primaryKey: true, autoIncrement: true },
    username: {
      type: STRING(50),
      allowNull: false,
    },
    password: {
      type: STRING(255),
      allowNull: false,
    },
    gender: {
      type: INTEGER,
      allowNull: false,
    },
    avatar: {
      type: STRING(255),
      allowNull: true,
    },
    phone: {
      type: STRING(11),
      allowNull: false,
    },
    birth_date: {
      type: DATE,
      allowNull: false,
    },
    height: {
      type: DECIMAL(5, 1),
      allowNull: false,
    },
    weight: {
      type: DECIMAL(5, 1),
      allowNull: false,
    },
    waist: {
      type: DECIMAL(5, 1),
      allowNull: false,
    },
    status: {
      type: BOOLEAN,
      allowNull: false,
      defaultValue: true,
    },
    created_at: DATE,
    updated_at: DATE,
  }, {
    tableName: 't_user',
  });

  return User;
};
